package com.tiger.cloud.controller.crm;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tiger.cloud.common.mybatis.BaseController;
import com.tiger.cloud.enums.DeleteEnum;
import com.tiger.cloud.filter.CurrentUserId;
import com.tiger.cloud.model.crm.AppSystemMessage;
import com.tiger.cloud.service.crm.IAppSystemMessageService;
import com.tiger.cloud.util.Response;
import com.tiger.cloud.util.ResponseUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 消息/通知
 */
@Controller
@RequestMapping(value = "systemMessage")
@Api(value = "消息/通知",tags = "消息/通知")
public class AppSystemMessageController extends BaseController {

	@Autowired
	private IAppSystemMessageService appSystemMessageService;
	
	/**
	 * 增量获取消息/通知
	 */
	@RequestMapping(value = "incrementRecommands", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "增量获取消息/通知",notes = "增量获取消息/通知")
	public Response incrementRecommands(@ApiParam(name="id",value="用户id",hidden=true) @CurrentUserId Long userId,@RequestBody  AppSystemMessage appSystemMessage){
		appSystemMessage.setIsDelete(DeleteEnum.NOMAIL);
		appSystemMessage.setReceiveUserId(userId);
		List<AppSystemMessage> recommandLists =appSystemMessageService.find(appSystemMessage);
		return ResponseUtil.ok(recommandLists);
	}
	
	/**
	 * 发送消息/通知
	 */
	@RequestMapping(value = "add", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "添加获取消息/通知",notes = "添加获取消息/通知")
	public Response add(@CurrentUserId Long userId,@RequestBody AppSystemMessage appSystemMessage){
		appSystemMessage.setSendUserId(userId);
		appSystemMessageService.insert(appSystemMessage);
		return ResponseUtil.ok();
	}

}